home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / POV-Ray 3.0.2 / Scenes / Zonohedra / Zonohedral Modules < prev   
Encoding:
Text File  |  1997-06-20  |  5.0 KB  |  125 lines  |  [TEXT/POV3]

  1. /*Polar zonohedra models, created within POV 3.0,
  2. by Russell Towle, June 1997. email: rustybel@foothill.net
  3.  
  4. Polar zonohedra are convex rhombic polyhedra determined by n vectors of equal magnitude. These vectors are identical to those connecting the apex to the base of a right regular n-gonal pyramid. Like such pyramids, polar zonohedra may be short and squashed, or tall and skinny. A polar zonohedron is symmetrical by a rotation of 360/n degrees around its symmetry axis, here coincident with the z axis.  This scene calls two "include" files and creates an ordinary polar zonohedron, with rhombic faces, but with spheres at each vertex and cylinders at each edge.  Switches are also provided to create only one or the other.
  5.  
  6. There are ten user-defined parameters in the procedure below:
  7.  
  8. 1.  N, the number of vectors; N>=3. Default: N=10.
  9. 2.  PITCH, the angle between the vectors and the xy plane; 0<=PITCH<=90 degrees. Default: PITCH=35.2643.
  10. 3.  A, the edge length. Default: D=tan(pi/N).
  11. 4.  B, the spheres' radius. Default: A/5.
  12. 5.  C, the cylinders' radius. Default: A/10
  13. 6.  T1, texture for the spheres. Default: texture{Gold_Metal}.
  14. 7.  T2, texture for the cylinders. Default: texture{T_Silver_1A}.
  15. 8.  T3, texture for the rhombic faces. Default: texture{Copper_Metal}.
  16. 9.  CYLLOHEDRON switch. Default: 1 (on).
  17. 10. POLAR_ZONOHEDRON switch. Default: 1 (on).
  18.  
  19. A polar zonohedron is the most spherical, and has the greatest volume for any given edge length, when PITCH = 35.2643+ degrees.  At that PITCH, polar zonohedra are isometric, orthogonal, solid shadows of N-cubes. The default scaling forces approximate unit equatorial radius; however, because the polar diameter varies according to PITCH, these forms may still stretch out of camera view when PITCH is high.
  20.  
  21. They are centered upon the z axis, with the sphere at the "south" pole just kissing the z=0 plane, whatever the PITCH. The camera and light statements will be found below the CYLLOHEDRON routine, since they use variables defined in that routine.*/
  22.  
  23. //-------------------------------------------------------------
  24. //includes and default texture
  25. //-------------------------------------------------------------
  26.  
  27. #version 3.0
  28. global_settings { assumed_gamma 2.2 }
  29. #include "colors.inc"
  30. #include "shapes.inc"
  31. #include "glass.inc"
  32. #include "metals.inc"
  33. #include "textures.inc"
  34. #default {texture{pigment{color White}finish{phong 0.01 ambient 0.2 diffuse 0.6}}}
  35.  
  36. //-------------------------------------------------------------
  37. //"switches" to turn the objects on or off
  38. //-------------------------------------------------------------
  39.  
  40. #declare CYLL_ON = 1  //set to zero to turn it off
  41. #declare PZ_ON   = 1  //set to zero to turn it off
  42.  
  43. //-------------------------------------------------------------
  44. //The two most important user-defined parameters; scaling
  45. //-------------------------------------------------------------
  46.  
  47. #declare N = 10            //choose an integer >= 3
  48. #declare PITCH = 35.2643  // 0<=pitch<=90 degrees
  49.  
  50. #declare A = tan(pi/N)    //scale factor; force equatorial radii to approx. 1
  51. #declare B = A/5    //ball size; A/5 default
  52. #declare C = A/10   //cylinder size; A/10 default
  53.  
  54. //-------------------------------------------------------------
  55. //textures for spheres, cylinders, rhombic faces
  56. //-------------------------------------------------------------
  57.  
  58. #declare T1 = texture{Gold_Metal}   //Gold_Metal good default
  59. #declare T2 = texture{T_Silver_1A}  //T_Silver_1A good default
  60. #declare T3 = texture{Copper_Metal} //Copper_Metal good default
  61.  
  62. //-------------------------------------------------------------
  63. //variables ...
  64. //-------------------------------------------------------------
  65.  
  66. #declare RISE = A * tan(radians(PITCH)) 
  67. #declare NORTH = <0,0,(B/2)+(N*RISE)>  //put the north pole here
  68. #declare SOUTH = <0,0,B/2> //put the south pole here
  69.  
  70. //-------------------------------------------------------------
  71. //objects created if switches "on"
  72. //-------------------------------------------------------------
  73.  
  74. #if (CYLL_ON)
  75. #include "CYLLO.inc"
  76. #end
  77. #if (PZ_ON)
  78. #include "PZ.inc"
  79. #end
  80.  
  81. //-------------------------------------------------------------
  82. //camera, pointing at center of object(s); lights
  83. //-------------------------------------------------------------
  84.  
  85. camera {
  86.     location <.1, -5, 10>
  87.     direction <0, 0, 3.75>
  88.     up <0, 0, 1>
  89.     right <4/3, 0, 0>
  90.     sky <0., 0., 1.>
  91.     look_at <0, 0, (B/2)+((N/2)*RISE)> //look at center of CYLLOHEDRON
  92.     rotate<0,12,0>
  93. }
  94.  
  95. light_source {<8, -12, 22> color rgb <1, 1, 1>}
  96. light_source {<0, 0, 15> color rgb <1, 1, 1>}//(B/2)+((N/2)*RISE) center
  97.  
  98. //-------------------------------------------------------------
  99. //objects shown if switches "on"
  100. //-------------------------------------------------------------
  101.  
  102. #if (CYLL_ON)
  103. object{CYLLOHEDRON}
  104. #end
  105. #if (PZ_ON)
  106. object{POLAR_ZONOHEDRON}
  107. #end
  108.  
  109. plane{z, 0
  110.  texture {
  111.       pigment { colour red 1.0 green 0.6 blue 0.2 }
  112.       normal {
  113.          ripples 1
  114.          frequency 20.0
  115.          scale 4.0
  116.       }
  117.       finish {
  118.          
  119.          ambient 0.2
  120.          diffuse 0.6
  121.       }
  122.    }
  123. }
  124.  
  125.